#ifndef WORKER_H
#define WORKER_H

#include <QObject>
#include "QSerialPort"
#include "QSerialPortInfo"
#include "QTimer"

#define IMAGE_WIDTH 320
#define IMAGE_HIGHT 240

class Worker : public QObject
{
    Q_OBJECT
public:
    union PixArray{
        quint8 img8Data[IMAGE_WIDTH*IMAGE_HIGHT*2*2];
        quint16 img16Data[IMAGE_WIDTH*IMAGE_HIGHT*2];
        quint32 img32Data[IMAGE_WIDTH*IMAGE_HIGHT];
    };
public:
    explicit Worker(QObject *parent = nullptr);
    ~Worker();
public slots:
    void doWork(void);
    void timeOut();
signals:
    void resultReady(quint8 *data,quint32 size);

private:
    QSerialPort *m_Port;
    QTimer *timer;
    bool recive_flag;
    union PixArray m_imgData[5];
    quint32 m_usbSpeed;
};

#endif // WORKER_H
